//
// Author: Vladimir Migashko <migashko@gmail.com>, (C) 2011
//
// Copyright: See COPYING file that comes with this distribution
//

#ifndef FASYS_FASYS_MESSAGES_CHANNELS_HPP
#define FASYS_FASYS_MESSAGES_CHANNELS_HPP

#include "types.hpp"
#include <list>
#include "message.hpp"
#include "channel_info.hpp"

namespace fasys{

class messages_container;
class channels_container;

class messages_channels
{
public:
  virtual ~messages_channels();
  messages_channels();
  messages_channels(channels_container* global_channels);
protected:
  messages_channels( const messages_channels& mc);
public:
  channel_id_t create(const std::string& channel, size_t min_size, size_t max_size);
  channel_id_t create(const std::string& channel);
  void publish(message& m);
  channel_id_t republish(const message& m);

  void move_all( std::list<message>& ml);
private:
  channel_info _create_channel( const std::string& channel );
private:
  messages_container* _messages;
  channels_container* _channels;
  channels_container* _global_channels;
  bool _owner_channels;
};

}

#endif
